<h1>Results for exam <%= @exam.exam.title %></h1>
<% @exam.exam.questions.each do |q| %>
	<p>
		<h2>Question: </h2><%=parse_images h q.text%><br/>
		<h2>Score: </h2><%=h q.score %><br/>
		<h2>Type: </h2><%= 
			if q.checkbox == 0
				"checkbox"
			else
				"radiobutton"
			end
		%>
		<p>
		<h2>Answers: </h2><br/>
			<% q.answers.each do |a| %>
				<%= parse_images h a.text %> - <%= 
					tmp = "wrong"
					tmp = "correct" if a.correctness == 1 
					tmp
				%><br/>
				<h2>Your answer is: </h2>
				<%= 
					tmp = nil
					@user_answers.each do |ua|
						if ua.answer == a
							tmp = ua
						end
					end
					if(tmp.nil? || tmp.correctness != a.correctness)
						"<span class=\"incorrect_answer\">wrong</span>"
					else
						"<span class=\"correct_answer\">correct</span>"
					end
				%> 
			<% end %>
		</p>
	</p>
<% end %>
<p>
	You reached <%=h @exam.score %> scores of 
	<%=h @exam.max_score %> scores<br/>
	You have a <%= get_grade(@exam) %>
</p>

<%= link_to 'Back', :action => 'list' %>
	